package com.suray.system.run.data.mysql.device.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.suray.system.run.core.ErrorDescription;
import com.suray.wcs.service.util.WcsUtil;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.util.Objects;

@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("wcs_error_des")
public class ErrorDesDB extends ErrorDescription {
    @TableId(value = "error_des_id", type = IdType.AUTO)
    private int errorDesId;

    public void copy(ErrorDescription errorDescription) throws Exception {
        WcsUtil.copy(errorDescription, this);
    }

    @Override
    public String toString() {
        return "ErrorDesDB{" +
                "errorDesId=" + errorDesId +
                '}' + super.toString();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        if (!super.equals(o)) return false;
        ErrorDesDB that = (ErrorDesDB) o;
        return errorDesId == that.errorDesId;
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), errorDesId);
    }
}
